package com.godz.getter.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.getter.mapper.GoodsMapper;
import com.godz.getter.mapper.SellerMapper;
import com.godz.getter.pojo.Goods;
import com.godz.getter.pojo.Seller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class prodController {
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    SellerMapper sellerMapper;

    @RequestMapping("/Produce")
    public String aboutUs(Model model, @RequestParam(value = "gid") int gid) {
        Goods goods = goodsMapper.selectOne(new QueryWrapper<Goods>().eq("gid", gid));
        String stuId = goods.getGStuId();
        Seller seller = sellerMapper.selectOne(new QueryWrapper<Seller>().eq("sel_id", stuId));
        model.addAttribute("goods", goods);
        model.addAttribute("seller", seller);
        return "details";
    }
}
